package org.easybuy.servlet;

/**
 * @author 许高峰
 *@商品servlet
 *
 */
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.mail.Session;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.easybuy.entity.Product;
import org.easybuy.service.ProductService;
import org.easybuy.serviceimpol.ProductServiceImpol;

public class ProductServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=utf-8");
		HttpSession session = request.getSession();
		String id3 = request.getParameter("ID3");
		PrintWriter out = response.getWriter();
		List<Product> list = new ArrayList<Product>();
		ProductService productServlet = new ProductServiceImpol();
		int i3d = Integer.parseInt(id3);
		list = productServlet.getAllProductBy3Id(i3d);
		session.setAttribute("SHOW_ALL_PRODUCT", list);
		request.getRequestDispatcher("../BrandList.jsp")
				.forward(request, response);

	}

}
